package at.sysarch.main;

import java.io.FileNotFoundException;

import at.sysarch.filter.LineToListFilter;
import at.sysarch.filter.ShiftListFilter;
import at.sysarch.filter.Sink;
import at.sysarch.filter.SortShiftsFilter;
import at.sysarch.filter.Source;

/**
 * 
 * @author Andi
 *
 * Helper class to wrap creation and starting of the pipeline.
 */
public class IndSys {
	
	private Source _source;
	private LineToListFilter _lineToListFilter;
	private ShiftListFilter _shiftListFilter;
	private SortShiftsFilter _sortShiftsFilter;
	private Sink _sink;

	public IndSys() throws FileNotFoundException {
		
		_source = new Source();
		_lineToListFilter = new LineToListFilter();
		_shiftListFilter = new ShiftListFilter();
		_sortShiftsFilter = new SortShiftsFilter();
		_sink = new Sink();
		
		_source.setOutput(_lineToListFilter);
		_lineToListFilter.setInput(_source);
		_lineToListFilter.setOutput(_shiftListFilter);
		_shiftListFilter.setInput(_lineToListFilter);
		_shiftListFilter.setOutput(_sortShiftsFilter);
		_sortShiftsFilter.setInput(_shiftListFilter);
		_sortShiftsFilter.setOutput(_sink);
		_sink.setInput(_sortShiftsFilter);
	}
	
	public void runSource() {
		try {
			_source.initialize();
			_source.run();
		} catch (FileNotFoundException e) {

			e.printStackTrace();
		}
	}
	
	public void runSink() {
		try {
			_source.initialize();
			_sink.run();
		} catch (FileNotFoundException e) {

			e.printStackTrace();
		}
	}
	
	public Sink getSink() {
		
		return _sink;
	}
}
